package beans;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import utils.ADFUtil;
import utils.JSFUtil;

public class PurchaseRequisition  {
    private String pRNo;
    private String dateField;
    private String requestedBy;
    private String requestedTo;
    private String approvedBy;
    private String itemType;
    private String manufacture;
    private String modelNumber;
    private String quantity;
    private String additionalRequirement;
    private String remarks;
    private String createdDate;
    private String createdBy;
    private List<Configuration> config;
    private String uuid;
    private int configCount=0;
    private Configuration configObject ;
    public PurchaseRequisition() {
      
            uuid = UUID.randomUUID().toString();
            config = new ArrayList<Configuration>();
             configObject = new Configuration();
            configObject.setParentUuid(uuid);
            config.add(configObject);
            configCount++;
        
       
        
    }
  

    public void setPRNo(String pRNo) {
        this.pRNo = pRNo;
    }

    public String getPRNo() {
        return pRNo;
    }

    public void setDateField(String dateField) {
        this.dateField = dateField;
    }

    public String getDateField() {
        return dateField;
    }

    public void setRequestedBy(String requestedBy) {
        this.requestedBy = requestedBy;
    }

    public String getRequestedBy() {
        return requestedBy;
    }

    public void setRequestedTo(String requestedTo) {
        this.requestedTo = requestedTo;
    }

    public String getRequestedTo() {
        return requestedTo;
    }

    public void setApprovedBy(String approvedBy) {
        this.approvedBy = approvedBy;
    }

    public String getApprovedBy() {
        return approvedBy;
    }

    public void setItemType(String itemType) {
        this.itemType = itemType;
    }

    public String getItemType() {
        return itemType;
    }

    public void setManufacture(String manufacture) {
        this.manufacture = manufacture;
    }

    public String getManufacture() {
        return manufacture;
    }

    public void setModelNumber(String modelNumber) {
        this.modelNumber = modelNumber;
    }

    public String getModelNumber() {
        return modelNumber;
    }

    public void setQuantity(String quantity) {
        this.quantity = quantity;
    }

    public String getQuantity() {
        return quantity;
    }

    public void setAdditionalRequirement(String additionalRequirement) {
        this.additionalRequirement = additionalRequirement;
    }

    public String getAdditionalRequirement() {
        return additionalRequirement;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setCreatedDate(String createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedDate() {
        return createdDate;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getUuid() {
        return uuid;
    }

    public void setConfig(List<Configuration> config) {
        this.config = config;
    }

    public List<Configuration> getConfig() {
        
        return config;
    }

    public void setConfigCount(int configCount) {
        this.configCount = configCount;
    }

    public int getConfigCount() {
        return configCount;
    }

  
    public String deleteConfig() {
        Object uuid =
            ADFUtil.resolveExpression("#{pageFlowScope.pConfigRemove}");
        if (uuid != null) {
            
                for (Configuration c : config) {
                    if (uuid.equals(c.getUuid())) {
                        config.remove(c);
                        return null;
                    }
              
            }
        }
        return null;
    }
    public String addConfig() {
        Object uuid =
            ADFUtil.resolveExpression("#{pageFlowScope.pRequestAdd}");
        Configuration configObject = new Configuration();
        configObject.setParentUuid(uuid.toString());
        config.add(configObject);
        configCount++;
        return null;
    }

    public void setConfigObject(Configuration configObject) {
        this.configObject = configObject;
    }

    public Configuration getConfigObject() {
        return configObject;
    }
}
